#include <stdio.h>
#include <string.h>

char outs[400][400];
int count[200];
char ins[100];

int main()
{
	int i, j, k, len, top;
	memset(count, 0, sizeof(count));
	memset(outs, 0, sizeof(outs));
	for (i=1; i<=4; ++i)
	{
		gets(ins);
		len = strlen(ins);
		for (j=0; j<len; ++j)
		{
			count[ins[j]]++;
		}
	}
	top = 0;
	for (i='A'; i<='Z'; ++i)
	{
		if (top < count[i]) top = count[i];
	}
	for (i=0; i<top; ++i)
	{
		for (j=1; j<=26; ++j)
		{
			k = j*2-1;
			if (count[j+'A'-1]+i >= top) 
				outs[i][k] = '*';
		}
	}
	for (j=1; j<=26; ++j)
	{
		k=j*2-1;
		outs[top][k] = j+'A'-1;
	}

	for (i=0; i<=top; ++i)
	{
		j = 100;
		while (outs[i][j] == 0) --j;
		while (--j>=0)
		{
			if (outs[i][j]==0) outs[i][j]=' ';			
		}
	}
	for (i=0; i<=top; ++i)
		printf("%s\n", outs[i]+1);


	return 0;
}